#include<bits/stdc++.h>
using namespace std;
int t,n;
int num[100005];
int suitation[100005];
int answer()
{
    int last_b=0;
    int last_r=0;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(suitation[i]==0)
        {
           if(num[i]==last_b)
                ans+=num[i];
           last_b=num[i];
        }
    }
    for(int i=0;i<n;i++)
    {
        if(suitation[i]==1)
        {
           if(num[i]==last_r)
                ans+=num[i];
           last_r=num[i];
        }
    }
    return ans;
}
int dfs(int h)
{
    if(h==n)
    return answer();
    else
    {
        int a,b;
        suitation[h]=0;
        a=dfs(h+1);
        suitation[h]=1;
        b=dfs(h+1);
        return max(a,b);
    }
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    for(int i=0;i<t;i++)
    {
        cin>>n;
        for(int i=0;i<n;i++)
         cin>>num[i];
         cout<<dfs(0)<<endl;
    }
}
